<?php
class protocol_event {
	const	unknown		= 0,
			privmsg		= 1,
			whois		= 2,
			nick		= 3,
			server		= 4,
			topic		= 5,
			invite		= 6,
			version		= 7,
			quit		= 8,
			squit		= 9,
			kill		= 10,
			info		= 11,
			links		= 12,
			stats		= 13,
			help		= 14,
			error		= 15,
			away		= 16,
			connect		= 17,
			ping		= 18,
			pong		= 19,
			pass		= 20,
			time		= 21,
			admin		= 22,
			sethost		= 23,
			nachat		= 24,
			setident	= 25,
			setname		= 26,
			lag			= 27,
			sdesc 		= 28,
			knock		= 29,
			credits		= 30,
			license		= 31,
			chghost		= 32,
			rping		= 33,
			rpong		= 34,
			netinfo		= 35,
			sendumode	= 36,
			addmotd		= 37,
			addomotd	= 38,
			svsmotd		= 39,
			smo			= 40,
			opermotd	= 41,
			tsctl		= 42,
			sajoin		= 43,
			sapart		= 44,
			chgident	= 45,
			notice		= 46,
			swhois		= 47,
			svso		= 48,
			svsfline	= 49,
			tkl			= 50,
			vhost		= 51,
			botmotd		= 52,
			htm			= 53,
			dccdeny		= 54,
			undccdeny	= 55,
			chgname		= 56,
			shun		= 57,
			cycle		= 58,
			module		= 59,
			svsnline	= 60,
			svspart		= 61,
			svslusers	= 62,
			svssno		= 63,
			svs2sno		= 64,
			svsjoin		= 65,
			svssilence	= 66,
			svswatch	= 67,
			join		= 68,
			part		= 69,
			lusers		= 70,
			eos			= 71,
			motd		= 72,
			mode		= 73,
			kick		= 74,
			rehash		= 75,
			restart		= 76,
			close		= 77,
			sendsno		= 78,
			dns			= 79,
			tempshun	= 80,
			silence		= 81,
			akill		= 82,
			unkline		= 83,
			rakill		= 84,
			globops		= 85,
			locops		= 86,
			protoctl	= 87,
			watch		= 88,
			trace		= 89,
			sqline		= 90,
			unsqline	= 91,
			svsnick		= 92,
			svsnoop		= 93,
			svskill		= 94,
			svsmode		= 95,
			samode		= 96,
			chatops		= 97,
			unzline		= 98,
			rules		= 99,
			map			= 100,
			svs2mode	= 101,
			dalinfo		= 102,
			adminchat	= 103,
			umode2		= 104,
			sjoin		= 105;
	static $_events	= array( 1 =>
			'privmsg',	'whois',	'nick',
			'server',	'topic',	'invite',
			'version',	'quit',		'squit',
			'kill',		'info',		'links',
			'stats',	'help',		'error',
			'away',		'connect', 'ping',
			'pong',		'pass',		'time',
			'admin',	'sethost',	'nachat',
			'setident',	'setname',	'lag',
			'sdesc',	'knock',	'credits',
			'license',	'chghost',	'rping',
			'rpong',	'netinfo',	'sendumode',
			'addmotd',	'addomotd',	'svsmotd',
			'smo',		'opermotd',	'tsctl',
			'sajoin',	'sapart',	'chgident',
			'notice',	'swhois',	'svso',
			'svsfline',	'tkl',		'vhost',
			'botmotd',	'htm',		'dccdeny',
			'undccdeny','chgname',	'shun',
			'cycle',	'module',	'svsnline',
			'svspart',	'svslusers','svssno',
			'svs2sno',	'svsjoin',	'svssilence',
			'svswatch',	'join',		'part',
			'lusers',	'eos',		'motd',
			'mode',		'kick',		'rehash',
			'restart',	'close',	'sendsno',
			'dns',		'tempshun',	'silence',
			'akill',	'unkline',	'rakill',
			'globops',	'locops',	'protoctl',
			'watch',	'trace',	'sqline',
			'unsqline',	'svsnick',	'svsnoop',
			'svskill',	'svsmode',	'samode',
			'chatops',	'unzline',	'rules',
			'map',		'svs2mode',	'dalinfo',
			'adminchat','umode2',	'sjoin');
    protected $_type = null;
	static function command_to_event ($command) {
		$command    = strtolower($command);
		$key	    = array_search($command,self::$_events);
		if (!$key) return self::unknown;
		else return $key;
	}
	static function event_to_command ($event) {
		if (array_key_exists($event,self::$_events))
			return self::$_events[$event];
		else
			return false;
	}
    public function __construct($command, basic $source, $parameters = null) {
        if ($source instanceof channel)
            throw new Exception("unexpected basic type in source");
        $this->_type = $this->command_to_event($command);
        $server = null;
        if ($source instanceof server)
            $server =& $source;
        elseif ($source instanceof user)
            $server =& $source->server
    }
}
?>